package socket;

import org.omg.PortableInterceptor.INACTIVE;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
 * Thread提供了一个静态方法:
 * static void sleep(long ms)
 * 可以使执行这个方法的线程进入阻塞状态指定毫秒,超时后线程会自动回到RUNNABLE状态再次并发执行
 */
public class SleepDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了");
        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("请输入倒计时");
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(
                    System.in //低级流,从控制台上读取内容
             )
            );
            String line = br.readLine();
            int time = Integer.parseInt(line);
            for (;time>=0;time--){
                Thread.sleep(1000);
                System.out.println(time);
            }
        } catch (InterruptedException | IOException e) {
            e.printStackTrace();
        }
        System.out.println("时间到");
    }
}
